﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.Data.SqlClient;
using System.Configuration;
using System.Globalization;
using System.Threading;
using ERPStudio;
using System.IO;
using System.Reflection;

namespace Administrare
{
    class dscModule: ModuleClass
    {
        public dscModule(Int16 codUnit, String numeUnit,String theme)
            : base(codUnit, numeUnit,theme)
        {

        }
        /// <summary>
        /// returneaza ID-ul intern pentru autorizare - 
        /// deriva din numele modului si este o cheie de control
        /// </summary>
        /// <returns></returns>
        override public String GetModuleID()
        {
            return "00";
        }


        /// <summary>
        /// incarca meniul acestui modul
        /// </summary>
        /// <param name="myMenu"></param>
        public void LoadMenu(ToolStripMenuItem mn, Form vForm, Guid appid, Guid userID)
        {
            base.LoadMenu(mn, (FrmMainMdi)vForm, appid, userID);
        }

        public void AfterLoadMenu(ToolStripMenuItem mn, Form vForm, Guid appid, Guid userID)
        {
           
        }

        public void toolStripButton1_Click(object sender, EventArgs e)
        {
            FrmMainMdi frm = mdiForm as FrmMainMdi;
            Assembly asm = frm.GetModule("erpforms");
            if (asm == null)
                return;

            String numeClasa = "ERPForms.DepartamenteFrm";
            Type mModule = asm.GetType(numeClasa);

            if (mModule != null)
            {
                FrmRezumat newFrm = asm.CreateInstance(numeClasa, true, BindingFlags.Public | BindingFlags.Instance | BindingFlags.CreateInstance, null,
                    new object[] { this }, Thread.CurrentThread.CurrentCulture, new object[] { }) as FrmRezumat;

                newFrm.MdiParent = frm;
                newFrm.Show();
            }
        }

        public void Aplicatii(object sender, EventArgs e)
        {
            AplicatiiFrm frm = new AplicatiiFrm(this);
            frm.MdiParent = mdiForm;
            frm.Show();
        }

        public void RoluriUtilizatori(object sender, EventArgs e)
        {
            UserRolesFrm frm = new UserRolesFrm(this);
            frm.MdiParent = mdiForm;
            frm.Show();
        }

        public void Meniuri(object sender, EventArgs e)
        {
            MeniuriFrm frm = new MeniuriFrm(this);
            frm.MdiParent = mdiForm;
            frm.Show();
        }

        private void BackupDataBase(object sender, EventArgs e)
        {
            //BackupRestoreFrm fImp = new BackupRestoreFrm(false);
            //fImp.MdiParent = mdiForm;
            //fImp.Show();

        }

        private void RestaurareDataBase(object sender, EventArgs e)
        {
            //BackupRestoreFrm fImp = new BackupRestoreFrm(true);
            //fImp.MdiParent = mdiForm;
            //fImp.Show();
        }

        public void Interogare(object sender, EventArgs e)
        {
            QueryFrm frm = new QueryFrm();
            frm.MdiParent = mdiForm;
            frm.Show();
        }

        public void FoxPro(object sender, EventArgs e)
        {
            FoxProFrm fImp = new FoxProFrm();
            fImp.MdiParent = mdiForm;
            fImp.Show();
        }

        public void Navigare(object sender, EventArgs e)
        {
            NavigareFrm frm = new NavigareFrm(this);
            frm.MdiParent = mdiForm;
            frm.Show();
        }

        /*public static void Nomenclatoare_Ocupatii(object sender, EventArgs e)
        {
            OcupatiiFrm frm = new OcupatiiFrm();
            frm.MdiParent = mdiForm;
            frm.Show();
        }
        public static void Nomenclatoare_TipStudii(object sender, EventArgs e)
        {
            TipStudiiFrm frm = new TipStudiiFrm();
            frm.MdiParent = mdiForm;
            frm.Show();
        }
        public static void Nomenclatoare_TipContracte(object sender, EventArgs e)
        {
            TipContracteFrm frm = new TipContracteFrm();
            frm.MdiParent = mdiForm;
            frm.Show();
        }
        public static void Nomenclatoare_TipGrad(object sender, EventArgs e)
        {
            TipGradFrm frm = new TipGradFrm();
            frm.MdiParent = mdiForm;
            frm.Show();
        }
        public static void Nomenclatoare_Judete(object sender, EventArgs e)
        {
            FrmMainMdi frm = mdiForm as FrmMainMdi;
            foreach (Assembly asm in frm.listaModule)
            {
                if (asm.FullName.ToLower().Contains("erpforms"))
                {
                    String numeClasa = "ERPForms.JudeteFrm";
                    Type mModule = asm.GetType(numeClasa);

                    if (mModule != null)
                    {
                        FrmRezumat newFrm = asm.CreateInstance(numeClasa) as FrmRezumat;
                        newFrm.MdiParent = frm;
                        newFrm.Show();
                    }
                    break;
                }
            }
        }
        public static void Nomenclatoare_Localitati(object sender, EventArgs e)
        {
            FrmMainMdi frm = mdiForm as FrmMainMdi;
            foreach (Assembly asm in frm.listaModule)
            {
                if (asm.FullName.ToLower().Contains("erpforms"))
                {
                    String numeClasa = "ERPForms.LocalitatiFrm";
                    Type mModule = asm.GetType(numeClasa);

                    if (mModule != null)
                    {
                        FrmRezumat newFrm = asm.CreateInstance(numeClasa) as FrmRezumat;
                        newFrm.MdiParent = frm;
                        newFrm.Show();
                    }
                    break;
                }
            }
        }
        public static void TipSpecialitati(object sender, EventArgs e)
        {
            TipSpecialitatiFrm frm = new TipSpecialitatiFrm();
            frm.MdiParent = mdiForm;
            frm.Show();
        }
        public static void TipPrezenta(object sender, EventArgs e)
        {
            TipPrezentaFrm frm = new TipPrezentaFrm();
            frm.MdiParent = mdiForm;
            frm.Show();
        }
        public static void ParametrizareModul(object sender, EventArgs e)
        {
            ResUmaSetupFrm frm = new ResUmaSetupFrm();
            frm.MdiParent = mdiForm;
            frm.Show();
        }
        public static void Pontaje(object sender, EventArgs e)
        {
            PontajFrm frm = new PontajFrm();
            frm.MdiParent = mdiForm;
            frm.Show();
        }
        public static void Unitati_functionale(object sender, EventArgs e)
        {
            FrmMainMdi frm = mdiForm as FrmMainMdi;
            foreach (Assembly asm in frm.listaModule)
            {
                if (asm.FullName.ToLower().Contains("erpforms"))
                {
                    String numeClasa = "ERPForms.UnitatiFrm";
                    Type mModule = asm.GetType(numeClasa);

                    if (mModule != null)
                    {
                        FrmRezumat newFrm = asm.CreateInstance(numeClasa) as FrmRezumat;
                        newFrm.MdiParent = frm;
                        newFrm.Show();
                    }
                    break;
                }
            }

        }*/

    }
}
